/* eslint-disable import/first */
/* eslint-disable react-hooks/rules-of-hooks */
/*
 * @Author: your name
 * @Date: 2021-10-11 21:00:32
 * @LastEditTime: 2021-11-10 18:03:08
 * @LastEditors: Shentong
 * @Description: 我的收藏
 * @FilePath: /distribution/src/pages/collect/index.tsx
 */
// eslint-disable-next-line @typescript-eslint/no-use-before-define
import React, {  useState,  useCallback  } from 'react';
import Taro, { useDidShow } from '@tarojs/taro';
import { View } from "@tarojs/components";

import styles from './index.module.scss'

import { getStoregeByKey } from '@/utils/index'

import ProdItem from '@/src/components/custom/prodItem';

import NoDataIcon from '@/src/assets/icon/noDataIcon.png'
import NoMore from "@/components/custom/no-more";

const FootMark = () => {
    const [list, setList] = useState([])

    const getDataList = useCallback(async () => {
      Taro.showLoading({ title: "加载中...", mask: true });

      const _list = await getStoregeByKey('footmark')

      setList(_list)

      Taro.hideLoading();
    }, [])

     // 点击进入商品详情页
   const shopItemClick = (item) => {
    Taro.navigateTo({
     url: `/pages/detail/index?shopId=${item.shopSId}`
   })
  }

    useDidShow(() => {
        getDataList()
    })

    return (
        <View className={styles.footmark}>
            <View>
                {
                    list.map((item, index) => {
                      return (<ProdItem
                        shop={item}
                        key={`shop_${index}`}
                        clickHandle={() => { shopItemClick(item) }}
                      />)

                    })
                }
                {list.length ? <NoMore /> : null}
            </View>

            {
                !list.length && <van-empty description='暂无数据' image={NoDataIcon} />
            }

        </View>
    )
}

export default FootMark
